﻿using FluentNHibernate.Conventions;
using FluentNHibernate.Conventions.Instances;

namespace ZenMoney.Core.DataAccess.Mappings.Conventions
{
	public class PropertyConvention : IIdConvention, IPropertyConvention, IReferenceConvention 
	{
		public void Apply(IPropertyInstance instance)
		{
			instance.Not.Nullable();
		}

		public void Apply(IIdentityInstance instance)
		{
			instance.GeneratedBy.Increment();
			instance.Column(instance.EntityType.Name + "Id");
		}

		public void Apply(IManyToOneInstance instance)
		{
			instance.Not.Nullable();			
		}
	}
}
